﻿using com.yoozoo.gta.Extension.UGUI.ScreenOrientationEx;
using UnityEngine;
using Yoozoo.UI.YGUI;

namespace com.yoozoo.gta.Extension.UGUI.ScreenOrientation.Adapter
{
    [System.Serializable]
    public class YMoreInfoEffectTextAdapterConfig : AdaptBaseConfig
    {
        public YTextStyle style;
        public YTextColorStyle styleColor;
        public TextAnchor alignment = (TextAnchor)DEFAULT_VALUE;

        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return false;
            }

            YMoreInfoEffectTextAdapterConfig other = (YMoreInfoEffectTextAdapterConfig)obj;
            if (style != other.style)
            {
                return false;
            }

            if (styleColor != other.styleColor)
            {
                return false;
            }

            if (alignment != other.alignment)
            {
                return false;
            }

            return true;
        }

        public override int GetHashCode()
        {
            int hash = 17;
            hash = hash * 23 + style.GetHashCode();
            hash = hash * 23 + styleColor.GetHashCode();
            hash = hash * 23 + alignment.GetHashCode();
            return hash;
        }
    }

    public class YMoreInfoEffectTextAdapter : AdaptBase<YMoreInfoEffectTextAdapterConfig, TextMoreInfoEffect>
    {
        protected override void CopyProperty(YMoreInfoEffectTextAdapterConfig config)
        {
            base.CopyProperty(config);
            config.style = mComponent.style;
            config.styleColor = mComponent.colorStyle;
            config.alignment = mComponent.alignment;
        }

        protected override void ApplyConfig(YMoreInfoEffectTextAdapterConfig config)
        {
            base.ApplyConfig(config);
            mComponent.style = config.style;
            mComponent.colorStyle = config.styleColor;
            if ((int)config.alignment != DEFAULT_VALUE)
            {
                mComponent.alignment = config.alignment;
            }
        }
    }
}